function [X_dot] = quadrotor_plant4(x,U)

global m g I
global a1 a2 a3 
global b1 b2 b3 
global kt kd
X_dot = zeros(12,1);

Ux = cos(x(1))*sin(x(3))*cos(x(5))+sin(x(1))*sin(x(5));
Uy = cos(x(1))*sin(x(3))*sin(x(5))-sin(x(1))*cos(x(5));

omega1 = sqrt(abs(U(1)/(4*kt) + U(3)/(2*kt) + U(4)/(4*kd)));
omega2 = sqrt(abs(U(1)/(4*kt) - U(2)/(2*kt) - U(4)/(4*kd)));
omega3 = sqrt(abs(U(1)/(4*kt) - U(3)/(2*kt) + U(4)/(4*kd)));
omega4 = sqrt(abs(U(1)/(4*kt) + U(2)/(2*kt) - U(4)/(4*kd)));
omega = omega1 - omega2 + omega3 - omega4;

% D = randn(1);
D = 0 ;
X_dot(1) = x(2);
X_dot(2) = x(4)*x(6)*a1 + U(2)*b1 - I*x(4)*omega + D;
X_dot(3) = x(4);
X_dot(4) = x(2)*x(6)*a2 + U(3)*b2 + I*x(2)*omega + D;
X_dot(5) = x(6);
X_dot(6) = x(2)*x(4)*a3 + U(4)*b3 + D;
X_dot(7)  = x(8); 
X_dot(8)  = Ux*U(1)/m + D;
X_dot(9)  = x(10); 
X_dot(10) = Uy*U(1)/m + D;
X_dot(11) = x(12); 
X_dot(12) = -g + cos(x(1))*cos(x(3))*U(1)/m + D;
end 